//
//  CZOrginal.swift
//  weibo24
//
//  Created by 李文峰 on 16/3/4.
//  Copyright © 2016年 fengten. All rights reserved.
//

import UIKit
import SnapKit

let CallMargin = 10
class CZOrginal: UIView {
    
    var statuesViewModel: CZStatusViewModel?{
        didSet{
            
            nameLable.text = statuesViewModel?.statuesModel?.user?.screen_name
            concentLable.text = statuesViewModel?.statuesModel?.text
            
            renImageView.image = statuesViewModel?.verifity_image
            VIPImage.image = statuesViewModel?.level_image
            
            
            
        }
    }
    

 //三部曲
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    //添加子控件  约束
    private func setupUI(){
        
        addSubview(touImageView)
        addSubview(renImageView)
        addSubview(nameLable)
        addSubview(VIPImage)
        addSubview(timeLable)
        addSubview(sourceLable)
        addSubview(concentLable)
        
        
        //约束
        //头像
        touImageView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left).offset(CallMargin)
            make.top.equalTo(self.snp_top).offset(CallMargin)
            
            make.size.equalTo(CGSizeMake(40, 40))
        }
        //认证图片
        renImageView.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(touImageView.snp_right)
            make.centerY.equalTo(touImageView.snp_bottom)
        }
        //名字
        nameLable.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(touImageView.snp_right).offset(CallMargin)
            make.top.equalTo(touImageView.snp_top)
        }
        //vip
        VIPImage.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(nameLable.snp_centerY)
            make.left.equalTo(nameLable.snp_right).offset(CallMargin)
        }
        //时间
        timeLable.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(touImageView.snp_right).offset(CallMargin)
            make.top.equalTo(nameLable.snp_bottom).offset(CallMargin/2)
            
        }
        //来源
        sourceLable.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(timeLable.snp_right).offset(CallMargin)
            make.bottom.equalTo(timeLable.snp_bottom)
            
        }
        //内容
        concentLable.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(touImageView.snp_bottom).offset(CallMargin)
            make.bottom.equalTo(self.snp_bottom)
            make.left.equalTo(self.snp_left).offset(CallMargin)
            make.right.equalTo(self.snp_right).offset(CallMargin)
        }
        
    }
    
    //懒加载
    //头像
    private lazy var touImageView: UIImageView = {
        
        let img = UIImageView()
        
        img.image = UIImage(named: "avatar_default_big")
        
        return img
        }()
    
    //认证图片
    private lazy var renImageView: UIImageView = {
        
        let img = UIImageView()
        
        img.image = UIImage(named: "avatar_vip")
        
        return img
        
        }()
    
    //名字
    private lazy var nameLable: UILabel = {
        
        let lb = UILabel()
        
        lb.text = "微博名字"
        lb.font = UIFont.systemFontOfSize(15)
        lb.textColor = UIColor.blackColor()
        
        return lb
        
        }()
    //会员等级
    private lazy var VIPImage: UIImageView = {
        
        let img = UIImageView()
        
        img.image = UIImage(named: "common_icon_membership_level1")
        
        return img
        
        }()
    
    //时间
    private lazy var timeLable: UILabel = {
        
        let lb = UILabel()
        
        lb.text = "时间"
        lb.font = UIFont.systemFontOfSize(13)
        lb.textColor = UIColor.orangeColor()
        
        return lb
        
        }()
    //来源
    private lazy var sourceLable: UILabel = {
        
        let lb = UILabel()
        
        lb.text = "微博来源"
        lb.font = UIFont.systemFontOfSize(13)
        
        return lb
        
        }()
    //内容
    private lazy var concentLable: UILabel = {
        
        let lb = UILabel()
        
        lb.text = "微博内容"
        lb.font = UIFont.systemFontOfSize(15)
        lb.numberOfLines = 0
        
        
        return lb
        
        }()
    
}
